package com.changgou.controller;

import com.alibaba.fastjson.JSON;
import com.changgou.entity.PageResult;
import com.changgou.entity.Result;
import com.changgou.feign.OrderFeign;
import com.changgou.feign.SkuFeign;
import com.changgou.pojo.Order;
import com.changgou.pojo.OrderItem;
import com.changgou.pojo.Sku;
import com.changgou.web.CasUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Project: com.changgou.controller
 * @Author: ShaoDi Wang
 * @Date: Created in 2019-08-12 11:47
 * @Description:
 * @Version: 1.0
 */
@RestController
@RequestMapping("/ordercenter")
public class OrderCenterController {

    @Autowired
    private OrderFeign orderFeign;

    @Autowired
    private SkuFeign skuFeign;

    /**
     * 分页多条件查询所有订单
     * @param searchMap
     * @param page
     * @param size
     * @return
     */
    @GetMapping(value = "/search/{page}/{size}")
    public Result findPage(@RequestParam Map searchMap,
                           @PathVariable Integer page, @PathVariable Integer size){
        if(page <= 0){
            page = 1;
        }
        if(size <=0){
            size = 5;
        }
        searchMap.put("username",CasUtil.loginName());
        return orderFeign.findPage(searchMap, page, size);
    }
}
